<?php


namespace App\Utils\Notice;


abstract class Notice
{

    public $model = null;

    public $data;

    public $receiverId;

    public function __construct(array $data = [])
    {
        $this->data = $data;
    }

    abstract public function toDatabase();


    public function isBindModel()
    {
        return $this->model ? true : false;
    }

    public function process()
    {
        $this->toDatabase();
    }


    protected function sprintf($template, $replaces)
    {
        $searches = [];
        foreach ($replaces as $replace => $content) {
            $searches[] = "%{$replace}%";
        }
        return str_replace($searches, $replaces, $template);
    }


}